fix: await ln payment before gift card confetti#929
Open
Conversation
Member
Author
|
Looking for a reliable way to reproduce it |
Member
Author
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25dd0c6052
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ovitrif
previously approved these changes
May 7, 2026
Collaborator
Member
Author
Contributor
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR:
Description
1. False-positive confetti
BlocktankRepo.claimGiftCodeWithLiquiditypreviously returned success as soon as Blocktank'sgiftPayHTTP RPC returned — but that response only confirms the LSP accepted the request, not that the LN payment actually landed. If Blocktank's background payer subsequently failed to route the HTLC, Bitkit still played confetti and surfaced a "received" sheet with the requested amount, while no incoming payment ever arrived.The repo now subscribes to
LightningRepo.nodeEventsfor theEvent.PaymentReceivedmatching the freshly-created invoice's payment hash before triggeringgiftPay, then awaits that event with a 45 second timeout. On timeout it throwsServiceError.GiftClaimPaymentNotReceived, which the existing error handler inGiftViewModelroutes to the standardGiftRoute.Errorscreen. The success result reports the actual received sat amount instead of the requested amount.The without-liquidity path (channel open +
openChannel) is unchanged — that path already blocks on the funding transaction.2. Intent re-delivery on Activity recreate
When the app language is changed, Android destroys and recreates the Activity, re-delivering the original launching intent.
MainActivity.onCreatewas unconditionally callinghandleDeeplinkIntent(intent), so any deeplink-driven flow (gift sheet, send sheet, pubky auth, etc.) re-fired on the locale switch.onCreatenow only processes the launching intent on a fresh start (savedInstanceState == null). New deeplinks that arrive while the app is running are still handled viaonNewIntent.Preview
N/A
QA Notes
Reproducing the failure path
The originally-reported
gUCdzXfm12V71xztGzDoiQ-3000is now exhausted and returnsGIFT_CODE_USED_UP(a separate, already-handled path), so it can no longer reproduce the false-positive. To exercise case 1, use one of:giftPayreturns success butEvent.PaymentReceivednever fires.Regtest helpers
Fire the gift deeplink directly without scanning a QR (replace the package id per flavor —
to.bitkit.devfor dev/regtest,to.bitkit.tnetfor testnet,to.bitkitfor mainnet):adb shell am start -a android.intent.action.VIEW -d "bitkit://gift-gUCdzXfm12V71xztGzDoiQ-3000" to.bitkit.dev